//
//  DYYuleSubCell.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/4.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit
import YYText

class DYYuleSubLanCell: SYBaseCell {
    
    let nameLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x1E1E1E)
        v.font = 15.autoFontSize()
        return v
    }()
    
    let tagLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x666666)
        v.font = 11.autoFontSize()
        
        return v
    }()
    
    let priceLb: YYLabel = {
        let v:YYLabel = YYLabel()
        v.textColor = UIColor(hex: 0xF55035)
        v.font = 15.autoFontSize()
        
        return v
    }()
    
//    let distanceLb: UILabel = {
//        let v:UILabel = UILabel()
//        v.textColor = UIColor(hex: 0x333333)
//        v.font = 10.autoFontSize()
//        v.text = "南京-六合区-环龙池路"
//        return v
//    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        
        v.layer.cornerRadius = 3.autoWidth()
        return v
    }()

    public func configureView(_ model:DYTourHotelVOListModel) {
        nameLb.text = model.name
        tagLb.text =  "\(model.label ?? "")  |  \(model.distance ?? "")"
        
        let showStr = "¥\(model.rates) 起"
        let attString = NSMutableAttributedString(string: showStr)
        attString.yy_setColor(UIColor(hex: 0xF55035), range: NSRange(location: 0, length: 1))
        attString.yy_setFont(10.autoFontSize(), range: NSRange(location: 0, length: 1))
        attString.yy_setColor(UIColor(hex: 0xF55035), range: NSRange(location: 1, length: showStr.count-2))
        attString.yy_setFont(14.autoFontSize(), range: NSRange(location: 1, length: showStr.count-2))
        attString.yy_setColor(UIColor(hex: 0xAFAFAF), range: NSRange(location: showStr.count-1, length: 1))
        attString.yy_setFont(10.autoFontSize(), range: NSRange(location: showStr.count-1, length: 1))
        priceLb.attributedText = attString
        pic.sy_setWithUrl(model.imgUrl)
    }
    
    override func initViews() {
        
        
        addSubview(nameLb)
        addSubview(tagLb)
        addSubview(priceLb)
//        addSubview(distanceLb)
        addSubview(pic)
        addSubview(lineView)
        nameLb.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(16.0.autoWidth())
            make.left.equalTo(pic.snp.right).offset(autoWidth(12.5))
            make.right.equalToSuperview().offset(autoWidth(-15.0))
            make.height.equalTo(14.5.autoWidth())
        }
        tagLb.snp.makeConstraints { (make) in
            make.top.equalTo(nameLb.snp.bottom).offset(autoWidth(9.5))
            make.left.equalTo(nameLb.snp.left)
            make.height.equalTo(15.0.autoWidth())
        }
        priceLb.snp.makeConstraints { (make) in
            make.bottom.equalTo(pic).offset(autoWidth(-1.0))
            make.height.equalTo(12.0.autoWidth())
            make.left.equalTo(nameLb.snp.left)
        }
//        distanceLb.snp.makeConstraints { (make) in
//            make.centerY.equalTo(tagLb.snp.centerY)
//            make.left.equalTo(locationPic.snp.right).offset(autoWidth(5.0))
//            make.right.equalToSuperview().offset(autoWidth(-15.0))
//            make.height.equalTo(15.autoWidth())
//        }
        pic.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(15.0.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(15.0))
            make.height.equalTo(85.0.autoWidth())
            make.width.equalTo(85.0.autoWidth())
            make.bottom.equalToSuperview().offset(-12.0.autoWidth())
        }
        lineView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            make.height.equalTo(0.5.autoWidth())
        }
    }
}

